<?php

/**
 * This is the model class for table "deposits".
 *
 * The followings are the available columns in table 'deposits':
 * @property integer $deposit_id
 * @property integer $user_id
 * @property integer $bank_id
 * @property integer $regionally
 * @property string $name
 * @property integer $increase
 * @property integer $taking
 * @property integer $taking_wop
 * @property integer $autoprolongation
 * @property string $payment
 * @property integer $min_balance_rub
 * @property integer $min_balance_usd
 * @property integer $min_balance_eur
 * @property string $info
 */
class Deposits extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Deposits the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'deposits';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('user_id, bank_id, regionally, name, increase, taking, taking_wop, autoprolongation, payment, min_balance_rub, min_balance_usd, min_balance_eur, info', 'required'),
			array('user_id, bank_id, regionally, increase, taking, taking_wop, autoprolongation, min_balance_rub, min_balance_usd, min_balance_eur', 'numerical', 'integerOnly'=>true),
			array('name, payment', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('deposit_id, user_id, bank_id, regionally, name, increase, taking, taking_wop, autoprolongation, payment, min_balance_rub, min_balance_usd, min_balance_eur, info', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		return array(
			'deposit_percents' => array(self::HAS_MANY, 'Deposit_Percents', 'deposit_id')
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'deposit_id' => 'Deposit',
			'user_id' => 'User',
			'bank_id' => 'Bank',
			'regionally' => 'Regionally',
			'name' => 'Name',
			'increase' => 'Increase',
			'taking' => 'Taking',
			'taking_wop' => 'Taking Wop',
			'autoprolongation' => 'Autoprolongation',
			'payment' => 'Payment',
			'min_balance_rub' => 'Min Balance Rub',
			'min_balance_usd' => 'Min Balance Usd',
			'min_balance_eur' => 'Min Balance Eur',
			'info' => 'Info',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('deposit_id',$this->deposit_id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('bank_id',$this->bank_id);
		$criteria->compare('regionally',$this->regionally);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('increase',$this->increase);
		$criteria->compare('taking',$this->taking);
		$criteria->compare('taking_wop',$this->taking_wop);
		$criteria->compare('autoprolongation',$this->autoprolongation);
		$criteria->compare('payment',$this->payment,true);
		$criteria->compare('min_balance_rub',$this->min_balance_rub);
		$criteria->compare('min_balance_usd',$this->min_balance_usd);
		$criteria->compare('min_balance_eur',$this->min_balance_eur);
		$criteria->compare('info',$this->info,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}